package com.midipad.controls;

import com.midipad.R;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.Log;
import android.view.MotionEvent;

/**
 * TODO (maybe some day)
 * @author Tim
 *
 */
public class Knob extends MidiController {

	public Knob(Context context, int x, int y, int width, int[] midiMessages) {
		super(context, 1, "KNOB", x, y, width, width, midiMessages);//only handle square knobs //TODO:really?
		//set up background
		this.setBackgroundDrawable(getResources().getDrawable(R.drawable.back_slider_9p));
	}

	@Override
	protected void onDraw(Canvas canvas) {
		Paint paint = new Paint();
		paint.setStyle(Paint.Style.STROKE);
		paint.setColor(Color.WHITE);
		//draw circles
		canvas.drawCircle(width/2, height/2, width/2/3, paint);
		canvas.drawCircle(width/2, height/2, width/2*5/6, paint);
		canvas.drawLine(width/2, height/2, 0, height, paint);
		canvas.drawLine(width/2, height/2, width, height, paint);
		//draw current value
		paint.setStyle(Paint.Style.FILL);
		//TODO
		paint.setColor(Color.RED);
		canvas.drawText(Integer.toString(midiValues[0]), width/2, height/2, paint);
	}

	@Override
	public void updateValues(int x, int y, MotionEvent me) {
		Log.d("KNOB", "x:"+x+" y:"+y+" width:"+width);
		// width/2, _ = 64 
		//TODO
		values[0] = y;
		midiValues[0] = 0;
	}

	@Override
	public void setValues(int val1, int val2, int val3) {
		// TODO Auto-generated method stub
		
	}

}
